import com.four.bmm.dao.IAdminDao;
import com.four.bmm.entity.Admin;
import com.four.bmm.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import java.util.List;

public class AdminTestDemo {
    SqlSession session = null;
    IAdminDao adminDao = null;

    @Before
    public void init() {
        session = SqlSessionFactoryUtil.getSqlSession();
        adminDao = session.getMapper(IAdminDao.class);
    }
    @Test
    public void testDemo1(){
        List<Admin> admins=adminDao.findAllUser();
        for (Admin admin:admins) {
            System.out.println(admin.getAdminname());
        }
    }
    @Test
    public void testDemo2(){
        Admin admins=new Admin("superadmin","123456");
        Admin admin=adminDao.adminLogin(admins);
       if(admin!=null){
           System.out.println(admin.getAdminname());
       }
    }


    @After
    public void destroy() {
        session.close();
    }
}
